package com.sznaner.tool.util;

import java.util.Locale;

public class LanguageUtil {

    //转阿拉伯文数字
    public static String toArNumberStr(String numberStr){
        if(numberStr == null) return null;
        numberStr = numberStr.replace("1","١");
        numberStr = numberStr.replace("2","٢");
        numberStr = numberStr.replace("3","٣");
        numberStr = numberStr.replace("4","٤");
        numberStr = numberStr.replace("5","٥");
        numberStr = numberStr.replace("6","٦");
        numberStr = numberStr.replace("7","٧");
        numberStr = numberStr.replace("8","٨");
        numberStr = numberStr.replace("9","٩");
        numberStr = numberStr.replace("0","٠");
        return numberStr;
    }

    //阿拉伯文数字转正常数字
    public static String toEnNumberStr(String numberStr){
        if(numberStr == null) return null;
        numberStr = numberStr.replace("١","1");
        numberStr = numberStr.replace("٢","2");
        numberStr = numberStr.replace("٣","3");
        numberStr = numberStr.replace("٤","4");
        numberStr = numberStr.replace("٥","5");
        numberStr = numberStr.replace("٦","6");
        numberStr = numberStr.replace("٧","7");
        numberStr = numberStr.replace("٨","8");
        numberStr = numberStr.replace("٩","9");
        numberStr = numberStr.replace("٠","0");
        return numberStr;
    }

    //中文环境
    public static Boolean is_zh(){
        if (Locale.getDefault().getLanguage().startsWith("zh")) {
            return true;
        }
        return false;
    }
    //英文环境
    public static Boolean is_en(){
        if (Locale.getDefault().getLanguage().startsWith("en")) {
            return true;
        }
        return false;
    }
    //阿拉伯语言
    public static Boolean is_ar(){
        if (Locale.getDefault().getLanguage().startsWith("ar")) {
            return true;
        }
        return false;
    }



}
